import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 25228
 * Date: 2024-07-21
 * Time: 10:05
 */
public class BorrowBooks implements Port{
    @Override
    public void work(BookList bookList) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入要借阅的书籍");
        String name =scanner.nextLine();
        int size=bookList.getUserSize();
        for(int i=0;i<size;i++){
            Book book=bookList.getBooks(i);
            if(book.getName().equals(name)&& !book.getExist()){
                System.out.println("已为你借阅");
                book.setExist(true);
                bookList.setBooks(book,i);
                return;
            }
        }
        System.out.println("借阅失败");
    }
}
